<div class="row">
    <div class="col-md-12">
        <div class="table-responsive">
            <table id="tb-active" class="table table-bordered table-hover tablesorter item-list" data-href='<?php echo admin_page_url(ADVERTISE_SLUG.'/cap-nhat/do'); ?>'>
                <thead>
                    <tr>
                        <th class="header"># <i class="fa fa-sort"></i></th>
                        <th class="header">Nội dung <i class="fa fa-sort"></i></th>
                        <th class="header">Người đăng <i class="fa fa-sort"></i></th>
                        <th class="header">Vị trí <i class="fa fa-sort"></i></th>
                        <th class="header">Thứ tự <i class="fa fa-sort"></i></th>
                        <th class="header">Liên kết <i class="fa fa-sort"></i></th>
                        <th class="header">Ngày bắt đầu <i class="fa fa-sort"></i></th>
                        <th class="header">Ngày kết thúc <i class="fa fa-sort"></i></th>
                        <th class="header">Hiển thị / Xoá</th>
                    </tr>
                    <tr class="tr-temp hidden warning">
                        <td colspan="10">
                            <form role="form" method="post">
                                <div class="col-md-6 col-xs-12">
                                    <div class="row">
                                        <div class="form-group col-md-6 col-xs-6">
                                            <label for="input-advertise-position">Vị trí</label>
                                            <select class="form-control" id="input-advertise-position" name="advertise[position]">
                                                <?php echo $sOptionPosition; ?>
                                            </select>
                                        </div>
                                        <div class="form-group col-md-6 col-xs-6">
                                            <label for="input-advertise-order">Thứ tự</label>
                                            <input type="text" class="form-control" id="input-advertise-order" name="advertise[order]" />
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="form-group col-md-6 col-xs-6">
                                            <label for="input-advertise-start-date-3">Ngày bắt đầu</label>
                                            <input type="text" class="form-control input-date" data-id="input-advertise-start-date-3" name="advertise[start_date]" autocomplete="off"/>
                                        </div>
                                        <div class="form-group col-md-6 col-xs-6">
                                            <label for="input-advertise-end-date-2">Ngày kết thúc</label>
                                            <input type="text" class="form-control input-date" data-id="input-advertise-end-date-3" name="advertise[end_date]" autocomplete="off" />
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label for="input-advertise-anchor">Liên kết</label>
                                        <input type="text" class="form-control" id="input-advertise-anchor" name="advertise[anchor]" />
                                    </div>
                                </div>

                                <div class="col-md-6 col-xs-12">
                                    <div class="checkbox">
                                        <label for="input-advertise-publish-flg">
                                            <input type="checkbox" id="input-advertise-publish-flg" name="advertise[publish_flg]" value="1" />Hiển thị
                                        </label>
                                    </div>
                                    <div class="checkbox">
                                        <label for="input-advertise-delete-flg">
                                            <input type="checkbox" id="input-advertise-delete-flg" name="advertise[delete_flg]" value="1"/> Xoá
                                        </label>
                                    </div>
                                    <div>
                                        <input type="hidden" name="advertise[id]" id="input-advertise-id" />
                                        <input type="hidden" name="case" value="<?php echo UPDATE_FULL; ?>" />
                                        <button type="button" class="btn btn-success btn-submit-update"><i class="glyphicon glyphicon-ok-sign"></i> Cập nhật</button>
                                        <button type="button" class="btn btn-danger btn-cancel-update"><i class="glyphicon glyphicon-remove-sign"></i> Huỷ</button>
                                    </div>
                                    <div class="clearfix"></div>
                                </div>
                            </form>
                        </td>
                    </tr>
                </thead>
                <tbody>
                    <?php foreach($aAdvertise as $index=>$ad) { ?>
                    <tr class="can-edit" data-id="<?php echo $this->encrypt->encode($ad->getId()); ?>">
                        <th class="header bg-info"><?php echo $index+1; ?></th>
                        <td class="input-advertise-content">
                            <a class="thumbnail maxW-365" href="<?php echo admin_advertise_single_url($ad->getId()); ?>">
                                <?php echo html_entity_decode($ad->getContent()); ?>
                            </a>
                        </td>
                        <td>
                            <?php
                                if($ad->getUserId()!=''){
                                    echo $ad->full_name;
                            ?>
                            <h4 class="mgt10">
                                <label class="label label-success">
                                    <i class="glyphicon glyphicon-ok-sign"></i>
                                    Người dùng hệ thống
                                </label>
                            </h4>
                            <?php
                                } else {
                                    $opt_info = unserialize($ad->getOptInfo());
                                    echo $opt_info['name'];
                            ?>
                            <h4 class="mgt10">
                                <label class="label label-warning">
                                    <i class="glyphicon glyphicon-ok-sign"></i>
                                    Khách
                                </label>
                            </h4>
                            <?php
                                }
                            ?>
                        </td>
                        <td class="input-advertise-position" data-position="<?php echo $ad->getPosition(); ?>"><?php echo $aPosition[$ad->getPosition()]; ?></td>
                        <td class="input-advertise-order"><?php echo $ad->getOrder(); ?></td>
                        <td class="input-advertise-anchor">
                            <a target="_blank" href="<?php echo $ad->getAnchor();?>" class="btn btn-info">
                                <i class="glyphicon glyphicon-share-alt"></i> Đi đến
                            </a>
                        </td>
                        <td class="input-advertise-start-date">
                            <?php echo fdate_format($ad->getStartDate()); ?>
                        </td>
                        <td class="input-advertise-end-date">
                            <?php echo fdate_format($ad->getEndDate()); ?>
                        </td>
                        <td class="input-advertise-flg">
                            <p class="input-advertise-flg">Hiển thị
                                <input id="chk-ad-publish-<?php echo $index + 1; ?>" class="lb-toggle checkbox" data-name="publish_flg" type="checkbox" <?php echo ($ad->getPublishFlg())==1?"checked='checked'":''; ?> />
                                <label for="chk-ad-publish-<?php echo $index + 1; ?>"></label>
                            </p>
                            <hr class="clearMgr" />
                            <p class="input-advertise-flg">Xoá
                                <input id="chk-ad-delete-<?php echo $index + 1; ?>" class="checkbox lb-toggle red" data-name="delete_flg" type="checkbox" <?php echo ($ad->getDeletedAt())!=NULL?"checked='checked'":''; ?> />
                                <label for="chk-ad-delete-<?php echo $index + 1; ?>"></label>
                            </p>
                            <p>
                                <a href="<?php echo admin_advertise_single_url($ad->getId()); ?>" class="btn btn-primary">
                                    <i class="glyphicon glyphicon-pencil"></i><br/>Cập nhật
                                </a>
                            </p>
                        </td>
                    </tr>
                    <?php } ?>
                </tbody>
            </table>
        </div>
    </div>
    <div class="clearfix"></div>
</div>

<div class="modal fade" id="modal-ad-preview">
    <div class="modal-dialog modal-sm">
        <div class="modal-content"></div>
    </div>
</div>